package com.chainyoung.component_tmperson.ui.mvp.model;

import com.chainyoung.common.appcommon.hdwallet.EtherscanService;
import com.chainyoung.common.di.scope.ActivityScope;
import com.chainyoung.common.integration.IRepositoryManager;
import com.chainyoung.common.mvp.BaseModel;
import com.chainyoung.common.utils.RxUtils;
import com.chainyoung.component_tmperson.api.PersonService;
import com.chainyoung.component_tmperson.entity.InviteFriend;
import com.chainyoung.component_tmperson.ui.mvp.contract.HdWalletContract;
import com.chainyoung.component_tmperson.ui.mvp.contract.InviteFriendContract;

import org.json.JSONObject;

import java.util.TreeMap;

import javax.inject.Inject;

import io.reactivex.Flowable;
import io.reactivex.annotations.NonNull;
import io.reactivex.functions.Function;
import okhttp3.ResponseBody;


public class HdWalletModel extends BaseModel implements HdWalletContract.Model {

    @Inject
    HdWalletModel(IRepositoryManager repositoryManager) {
        super(repositoryManager);

    }



    @Override
    public Flowable<String> getTransactions(String addr) {
        return mRepositoryManager.obtainRetrofitService(EtherscanService.class)
                .getAllNormalTranscation(addr)
                .map(new Function<ResponseBody, String>() {
                    @Override
                    public String apply(@NonNull ResponseBody body) throws Exception {
                        return new JSONObject(body.string()).getString("result");
                    }
                });
    }
}

